<template>
  <div class="box">
    <ul class="shang">
      <li><input type="text" placeholder="搜索" /></li>
      <li
        @click="handleClicktop(index)"
        v-for="(item, index) in listtop"
        :key="index"
        :class="{ active: dianjitop == index }"
      >
        {{ item.text }}
      </li>
    </ul>
    <div class="xia-box">
      <ul class="xia">
        <li
          @click="currentIndex = index"
          :class="{ active: currentIndex == index }"
          v-for="(item, index) in shopinfo.taglist"
          :key="index"
        >
          {{ item.name }}
        </li>
      </ul>
      <div class="right">
        <h2>热销</h2>
        <div class="list">
          <div
            class="one"
            v-for="(item, index) in shopinfo.taglist &&
            shopinfo.taglist[currentIndex].goodlist"
            :key="index"
          >
            <div class="img">
              <img :src="item.picture" alt="" />
            </div>
            <div class="you">
              <p class="name">{{ item.name }}</p>
              <p class="jieshao">{{ item.promotion_info }}</p>
              <p class="mai">{{ item.month_saled_content }}</p>
              <div class="btn">
                <span class="money">￥{{ item.min_price }} </span>
                <button>+</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { shop_shopinfo } from "../api";

export default {
  data() {
    return {
      currentIndex: 0, //用来保存分类下标
      shopinfo: {},
      dianjitop: 0,
      listtop: [{ text: "点餐" }, { text: "评价4.5" }, { text: "商家" }],
      dianji: 0,
    };
  },
  mounted() {
    // shop_shopinfo({ params: { id: this.$route.params.mtWmPoiId } }).then(
    //   (res) => {
    //     //判断跳转的路由页面在数据里是否有
    //     if (res.data.code == 200) {
    //       console.log(res.data.shopinfo);
    //       this.shopinfo = res.data.shopinfo; //如果有就跳转-
    //     } else {
    //       //如果找不到该商家
    //       alert(res.data.msg); //弹框数据里的信息
    //       this.$router.go(-1); //返回上一级菜单
    //     }
    //   }
    // );
    //方式二;
    shop_shopinfo({ id: this.$route.params.id }).then((res) => {
      //判断跳转的路由页面在数据里是否有
      if (res.data.code == 200) {
        console.log(res.data.shopinfo);
        this.shopinfo = res.data.shopinfo; //如果有就跳转-
      } else {
        //如果找不到该商家
        alert(res.data.msg); //弹框数据里的信息
        this.$router.go(-1); //返回上一级菜单
      }
    });
  },
  methods: {
    handleClicktop(index) {
      //保存点击的下标
      this.dianjitop = index;
    },
  },
};
</script>

<style scoped>
.shang {
  display: flex;
  padding: 10px;
}
.shang li {
  margin: 10px;
  height: 30px;
  /* border-bottom: 2px solid blue; */
}
.shang li input {
  height: 20px;
  width: 70px;
  border-radius: 8px;
  text-indent: 10px;
}
.shang .active {
  border-bottom: 3px solid blue;
  color: blue;
}

/* ------------------------------ */
.xia-box {
  display: flex;
}
.xia {
  width: 100px;
}
.right {
  flex: 1;
}
.xia li {
  height: 50px;
  margin: 20px 0;
  text-align: center;
  line-height: 50px;
}
.xia .active {
  border-left: 5px solid red;
}
.right h2 {
  margin: 10px;
}
.right .one {
  display: flex;
  height: 130px;
  margin: 10px;
}
.right .one .img {
  width: 120px;
  height: 120px;
  margin-right: 10px;
}
.right .one img {
  width: 100%;
  height: 100%;
}
.right .you {
  flex: 1;
  box-sizing: border-box;
}
.right .one .you .name {
  margin-bottom: 10px;
}
.right .one .you .jieshao,
.mai {
  font-size: 12px;
  color: rgb(130, 125, 125);
}
.right .one .you .btn {
  display: flex;
  justify-content: space-between;
  padding-right: 10px;
  margin-top: 10px;
}
.right .one .you .money {
  display: inline-block;
  color: red;
}
.right .one .you button {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: blue;
  border: 1px solid blue;
  color: white;
  font-size: 20px;
}
</style>